<?php

class Admin_YearController extends Zend_Controller_Action
{

    public function init(){  
    }
    public function indexAction(){
    }

    public function addAction()
    {
    	$form = new Application_Form_Year();
    	$form->appendValidationEngineFiles($this->view); 
    	$polish = BH_TranslatePL::getPolishTranslation();
  		$translate = new Zend_Translate('array', $polish, 'pl');
  		$form->setTranslator($translate);
    	
    	$form->submit->setLabel('Dodaj nowy rok');
		$this->view->YearForm = $form;
    	
    	$request = $this->getRequest();
    	if ($request->isPost()) {
    		if ($form->isValid($request->getPost())) {
    			$year = new Application_Model_Entities_Year();
    			$year->setFaculty( $form->getValue('facultyID') );
    			$year->setMajor( $form->getValue('majorID') );
    			$year->setNumberStudentYear( $form->getValue('numberStudentYear') );
    			$year->setNumberGroupLecture( $form->getValue('numberGroupLecture') );
    			$year->setAbundanceGroup( $form->getValue('abundanceGroup') );
    			$year->setTypeStudy( $form->getValue('typeStudyID') );
    			$year->setDegreeStudy( $form->getValue('degreeStudyID') );
    			$yearDao = new Application_Model_Dao_Year();
    			$yearDao->saveyear($year);
    		//	$result = Zend_Auth::getInstance()->authenticate($year);
    			//if ($result->isValid()) {
    				$this->_helper->redirector('index');
    			} else {
    				//$form->login->addError('Należy wypełnić wszystkie pola.');
    			}
    		//}
    	}
    }
}